const Admin = require("./modules/adminModule");

//登录
const login = async (userinfo) => {
  const { loginId, loginPwd } = userinfo;

  return await Admin.findOne({
    where: {
      loginId,
      loginPwd,
    },
    attributes: ["id", "name", "loginId"],
  });
};

//修改
const update = async (info) => {
  return await Admin.update(
    { loginPwd: info.loginPwd, name: info.name },
    {
      where: {
        loginId: info.loginId,
        loginPwd: info.oldLoginPwd,
      },
    }
  );
};

module.exports = {
  login,
  update,
};
